import { createI18n } from 'vue-i18n'
import enLocale from './lang/en'
import zhLocale from './lang/zh'
import store from '@/store'
const message = {
  en: {
    msg: {
      ...enLocale
    }
  },
  zh: {
    msg: {
      ...zhLocale
    }
  }
}

const getLanguage = () => {
  return store && store.getters && store.getters.language
}

const i18n = createI18n({
  legacy: false, // 使用组合式api
  globalInjection: true, // 全局使用 t 函数
  locale: getLanguage(),
  messages: message,
  warnHtmlMessage: false
})

export default i18n
